package com.tarena.lbs.user.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tarena.lbs.user.dao.mapper.UserMapper;
import com.tarena.lbs.user.dao.mapper.UserTagsMapper;
import com.tarena.lbs.user.dao.repository.UserRepository;
import com.tarena.lbs.user.pojo.param.UserParam;
import com.tarena.lbs.user.pojo.po.AdminPO;
import com.tarena.lbs.user.pojo.po.UserPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class UserRepositoryImpl implements UserRepository {
    @Autowired
    UserMapper userMapper;


    @Override
    public List<UserPO> listUser(UserParam param) {
        log.debug("查询用户信息", param);
        List<UserPO> list = userMapper.listUser(param);
        return list;
    }

    @Override
    public UserPO userLogin(String phone) {
        log.info("用户登录：{}", phone);
        UserPO userPO = userMapper.userlogin(phone);
        return userPO;
    }

    @Autowired
    UserTagsMapper userTagsMapper;
    @Override
    public void save(UserPO po) {
        log.debug("保存用户信息", po);
        userMapper.insert(po);
        log.debug("保存用户信息成功");
    }

    @Override
    public Long count(QueryWrapper queryWrapper) {
        log.debug("查询用户信息", queryWrapper);
        Long count = userMapper.selectCount(queryWrapper);
        return count;
    }

    @Override
    public UserPO getById(Integer id) {
        log.debug("查询用户信息", id);
        UserPO userPO = userMapper.selectById(id);
        return userPO;
    }
}
